<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
	<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
	<%@ page import="com.fBlog.pojo.Tuser" %>
	<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录</title>
<link rel="stylesheet" href="<%=basePath%>css/login.css">
<link rel="stylesheet" href="<%=basePath%>css/supersized.css">
<link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet">
<script type="text/javascript" src="<%=basePath%>js/tooltips.js"></script>
<script type="text/javascript" src="<%=basePath%>js/login.js"></script>
<script type="text/javascript" src="<%=basePath%>js/jquery.form.js"></script>
<script src="<%=basePath%>js/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
	function loginFun(e){
        $("#msg1").html("");
        $("#pwdInfo").html("");
        $("#usernameInfo").html("");
        $("#fmlyNameInfo").html("");
        var fname = $("input[name='fmlyName']").val();
		var name = $("input[name='userName']").val();
		var pwd = $("input[name='password']").val();
        if(fname==""){
            $("#fmlyNameInfo").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color='red'>*</font>&nbsp;请输入家庭昵称！");
        }else if(name==""){
            $("#usernameInfo").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color='red'>*</font>&nbsp;请输入用户名！");
		}else if(pwd==""){
			$("#pwdInfo").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color='red'>*</font>&nbsp;请输入密码！");
		}else{
			 	$.ajax({
			    type:"post",
			    url:"<%=basePath%>userController/login",      // 这里是提交到什么地方的url
			    data:{familyName:fname,userName:name,password:pwd},            // 这里把表单里面的数据放在这里传到后台
			    dataType:"json",
			    success:function(date){
			    	if(date=="0"){
			    		$("#msg1").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color='red'>*</font>&nbsp;登录成功！");
			    		window.location.href="<%=basePath%>pageController/index"
			    	}else if(date=="1"){
			    		$("#msg1").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color='red'>*</font>&nbsp;输入信息有误！");
			    	}else{
			    		$("#msg1").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color='red'>*</font>&nbsp;未知错误！");
			    	}
			    },
					/*同步git*/
			   /*  error:function(){  
			    	$("#msg").html("用户名或密码错误！"); 
	            }  */ 
			});
		}
	}
	function regPageFun(){
	    $("#msg1").html("");
        $("#pwdInfo").html("");
        $("#usernameInfo").html("");
        $("#fmlyNameInfo").html("");
		$("#login").hide('slow','swing',function () {
            $("#reg").show('fast');
        });
	}
	function noReg() {
        $("#familyNamemsg").html("");
        $("#adminmsg").html("");
        $("#password1msg").html("");
        $("#msg2").html("");
        $("#wrong").hide('fast');
        $("#right").hide('fast');
        $("#reg").hide('slow','swing',function () {
            $("#login").show('fast')
        });
    }
    function reset(){
        $("#fmlyName").val("");
        $("#userName").val("");
        $("#password").val("");
        $("#familyName").val("");
        $("#admin").val("");
        $("#password1").val("");
        $("#msg2").val("");
	    window.location.reload();
	}
	function checkPw() {
      //  document.getElementById("password1").readOnly=true;
        var password1 = $("input[name='password1']").val();
        var repassword1 = $("input[name='repassword1']").val();
        if(password1==repassword1) {
            $("#wrong").hide('fast');
            $("#right").show('slow');
        }else{
            $("#right").hide('fast');
         //   $("#wrong").show('slow');
		}
    }
	function regFun(e) {
        $("#familyNamemsg").html('');
        $("#adminmsg").html('');
        $("#password1msg").html('');
        var familyName = $("input[name='familyName']").val();
        var admin = $("input[name='admin']").val();
        var password1 = $("input[name='password1']").val();
        var repassword1 = $("input[name='repassword1']").val();
		if(familyName==''){
            $("#familyNamemsg").html('*');
		}
		if(admin==''){
            $("#adminmsg").html('*');
		}
		if(password1==''){
            $("#password1msg").html('*');
		}
		if(familyName!='' && admin!='' && password1!=''){
		    if(password1==repassword1){
              //  $("#wrong").hide('fast');
		        $("#right").hide('fast');
				//注册信息填写验证完成，开始注册
                $.ajax({
                    type:"post",
                    url:"<%=basePath%>userController/reg",      // 这里是提交到什么地方的url
                    data:{familyName:familyName,admin:admin,password1:password1},            // 这里把表单里面的数据放在这里传到后台
                    dataType:"json",
                    success:function(date){
                        if(date=="0"){
                            $("#msg2").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color='red'>*</font>&nbsp;注册成功！");
                        }else if(date=="1"){
                            $("#msg2").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color='red'>*</font>&nbsp;家庭昵称已存在！");
                        }else{
                            $("#msg2").html("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color='red'>*</font>&nbsp;未知错误！");
                        }
                    },
					/*  error:function(){
					 $("#msg").html("用户名或密码错误！");
					 }  */
                });
			}else{
                $("#right").hide('fast');
                $("#wrong").show('slow');
			}
		}
    }
</script>
</head>
<body style="background-size: 100% 100%; background-attachment: fixed;">
<div class="page-container">
	<div class="main_box">
		<div class="login_box">
			<div class="login_logo">
				<img src="images/logo.png" >
			</div>
			<div class="login_form" id="login">
				<form id="login_form" method="post">
					<div class="form-group">
						<label style="font-size:20px; font-family: 华文行楷" for="j_familyName" class="t">家庭昵称：</label>
						<input id="fmlyName" style="color: #0495ff; font-size:18px; font-family: 华文行楷" ;
							   value="" name="fmlyName" type="text" placeholder="请输入家庭昵称" class="form-control x319 in"
							   onkeydown="if(event.keyCode==13 || event.which==13){loginFun(event);}">
						<label id="fmlyNameInfo" style="font-size:18px;color: #c1089f; font-family: 华文行楷"></label>
					</div>
					<div class="form-group">
						<label style="font-size:20px; font-family: 华文行楷" for="j_username" class="t">用户名：</label>
						<input id="userName" style="color: #0495ff; font-size:18px; font-family: 华文行楷" value="" name="userName" type="text" placeholder="请输入用户名" class="form-control x319 in"
							   onkeydown="if(event.keyCode==13 || event.which==13){loginFun(event);}">
						<label id="usernameInfo" style="font-size:18px;color: #c1089f; font-family: 华文行楷"></label>
					</div>
					<div class="form-group">
						<label style="font-size:20px; font-family: 华文行楷" for="j_password" class="t">密　码：</label>
						<input id="password" style="color: #0495ff; font-size:15px; font-family: 华文行楷" value="" name="password" type="password" placeholder="请输入密码"
						class="password form-control x319 in" onkeydown="if(event.keyCode==13 || event.which==13){loginFun(event);}">
						<label id="pwdInfo" style="font-size:18px;color: #c1089f; font-family: 华文行楷"></label>
						<label id="msg1" style="font-size:18px;color: #c1089f; font-family: 华文行楷"></label>
					</div>
					<div class="form-group space">
						<label class="t"></label>　　　
						<button type="button" style="font-size:20px; font-family: 华文行楷"  id="submit_btn" onclick="loginFun()"
						class="btn btn-primary btn-lg">&nbsp;登&nbsp;录&nbsp; </button>
						<input type="reset" style="font-size:20px; font-family: 华文行楷" value="&nbsp;注&nbsp;册&nbsp;" class="btn btn-default btn-lg" onclick="regPageFun()">
					</div>
				</form>
			</div>
			<div id="reg" hidden="hidden">
				<form action="" id="reg_form" method="post">
					<div class="form-group">
					<label for="j_familyName" style="font-size:20px; font-family: 华文行楷" class="t">家庭昵称：</label>
					<input id="familyName" style="color: #0495ff; font-size:18px; font-family: 华文行楷" value="" name="familyName" type="text" placeholder="请给你的家庭取个名字" class="form-control x319 in"
						   onkeydown="if(event.keyCode==13 || event.which==13){regFun(event);}">
					<label id="familyNamemsg" style="font-size:25px;color: red; font-family: 华文行楷"></label>
					</div>
					<div class="form-group">
					<label for="j_admin" style="font-size:20px; font-family: 华文行楷" class="t">申请人：</label>
					<input id="admin" style="color: #0495ff; font-size:18px; font-family: 华文行楷" value="" name="admin" type="text" placeholder="请输入申请人名称" class="form-control x319 in"
						   onkeydown="if(event.keyCode==13 || event.which==13){regFun(event);}">
					<label id="adminmsg" style="font-size:25px;color: red; font-family: 华文行楷"></label>
					</div>
					<div class="form-group">
					<label for="j_password1" style="font-size:20px; font-family: 华文行楷" class="t">登录密码：</label>
					<input id="password1"  style="color: #0495ff; font-size:15px; font-family: 华文行楷" value="" name="password1" type="password" placeholder="请输入登录密码" class="form-control x319 in"
						   onkeydown="if(event.keyCode==13 || event.which==13){regFun(event);}">
					<label id="password1msg" style="font-size:25px;color: red; font-family: 华文行楷"></label>
					</div>
					<div class="form-group">
						<label for="j_password1" style="font-size:20px; font-family: 华文行楷" class="t">确认密码：</label>
						<input id="repassword1"  style="color: #0495ff; font-size:15px; font-family: 华文行楷" oninput="checkPw()" value="" name="repassword1" type="password" placeholder="请输入登录密码" class="form-control x319 in"
							   onkeydown="if(event.keyCode==13 || event.which==13){regFun(event);}">
						<img id="right" src="images/right.png" hidden>
						<img id="wrong" src="images/wrong.png" hidden>
						<label id="msg2" style="font-size:20px;color: #c1089f; font-family: 华文行楷"></label>
					</div>
					<div class="form-group space">
						<label class="t"></label>　　　
						<button type="button" style="font-size:20px; font-family: 华文行楷"  id="reg_btn" onclick="regFun()"
								class="btn btn-primary btn-lg">&nbsp;提&nbsp;交&nbsp; </button>
						<input type="reset" style="font-size:20px; font-family: 华文行楷" value="&nbsp;取&nbsp;消&nbsp;" class="btn btn-default btn-lg" onclick="noReg()">
					</div>
				</form>
			</div>
		</div>
		<div style="font-size:15px; font-family: 华文行楷" class="bottom">Copyright &copy; 家庭博客（2017） <a href="#" onclick="reset()">系统登陆</a></div>
	</div>
</div>

<!-- Javascript -->

<script src="<%=basePath%>js/supersized.3.2.7.min.js"></script>
<script src="<%=basePath%>js/supersized-init.js"></script>
<script src="<%=basePath%>js/scripts.js"></script>
	</body>
</html>